<?

if (null==$listfield1) $listfield1 = "code";
if (null==$listfield2) $listfield2 = "name";
if (null==$listfield3) $listfield3 = "publish";

if ($action=="search"){

	$Query = "select id, $listfield1, $listfield2, $listfield3 from $table WHERE $listfield1 Like '%$Search%' OR $listfield2 Like '%$Search%'   order by id desc Limit $Offset, $ListNum";

	$Query1 = "select count(*) as total from $table WHERE $listfield1 Like '%$Search%' OR $listfield2 Like  '%$Search%'";

}else{

	$Query = "select id, $listfield1, $listfield2, $listfield3 from $table order by id desc Limit $Offset, $ListNum";

	$Query1 = "select count(*) as total from $table";
	
}

$list = myQuery($Query);


$CountRecord = myQuery($Query1);

$CountNum = $CountRecord[0][0];
$Url="&Searcn=$Search&action=$action";	


print(splitPage($Url,$CountNum));

?>
<form name="form1" method="post" action="../../inc/mod_pub.php">
<input type="hidden" name="nonew" value="1">
        <table width="100%" border="0" cellspacing="1" cellpadding="1" class="tb">
          <tr class="tbheader"> 
            <td width="10%"><?print(ucfirst($listfield1))?></td>
            <td width="60%"><?print(ucfirst($listfield2))?></td>
			<td width="10%"><?print(ucfirst($listfield3))?></td>
			<td width="20%"></td>
          </tr>


<?
if ($list){
	for ($i=0;$i<count($list);$i++){?>
          <tr class="tbcontent1"> 
            <td><?print($list[$i][1])?></td>
            <td><?print($list[$i][2])?></td>
			<td align="center">
			  <input name="pub[<?=$list[$i][0]?>]" type="radio" id="pub[<?=$list[$i][0]?>]" value="yes" <? echo ($list[$i][3]=='yes')?"checked":"";?>> Y 
              <input name="pub[<?=$list[$i][0]?>]" type="radio" id="pub[<?=$list[$i][0]?>]" value="no" <? echo ($list[$i][3]=='no')?"checked":"";?>> N 
</td>
			<td align=center bgcolor="ECECEC">
			<a href="edit.php?id=<?print($list[$i][0])?>"><img src="<?print($rela_path)?>images/bt_edit.gif" border="0" alt="Edit"></a>
			<a href="delete.php?id=<?print($list[$i][0])?>"><img src="<?print($rela_path)?>images/bt_delete.gif" border="0" Alt="Delete"></a>
			<a href="enquire.php?id=<?print($list[$i][0])?>"><img src="<?print($rela_path)?>images/bt_enquiry.gif" border="0" Alt="Enquire"></a></td>
          </tr>
<?
	}
?>
          <tr class="tbcontent1"> 
            <td></td>
            <td></td>
            <td><div align="center">
              <input type="submit" name="submit" value="Save">
			  <input type="hidden" name="url" value="../media/news/news_menu.php">
			  <input type="hidden" name="table" value="<?=$table?>">
            </div></td>
			<td></td>
          </tr>
<?
}?>


        </table>
</form>
<?print(splitPage($Url,$CountNum))?>
